package com.macro.mall.portal.component;

import com.macro.mall.portal.util.HttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 定时任务，没2分钟装载一次ES
 * @author Yuheng
 */
@Component
public class LoadingEsTask {
    private Logger LOGGER = LoggerFactory.getLogger(LoadingEsTask.class);
//TODO 生产上放开
//    /**
//     * cron表达式：Seconds Minutes Hours DayofMonth Month DayofWeek [Year]
//     * 每2分钟扫描一次，扫描设定超时时间之前的所有商品，并加载到elasticsearch
//     */
//    @Scheduled(cron = "0 0/2 * ? * ?")
//    private void load(){
//        try {
//            String result = HttpUtils.getHttpResult("http://121.199.12.118/search/esProduct/add/product");
//            LOGGER.info("装载elasticsearch:"+result ,result);
//        } catch (IOException e) {
//            LOGGER.error("装载elasticsearch异常！！！！！！");
//        }
//    }
}
